package com.dy.system.service.impl;

import com.dy.basic.service.impl.BaseServiceImpl;
import com.dy.system.domain.SystemDictionaryDetail;
import com.dy.system.domain.SystemDictionaryType;
import com.dy.system.mapper.SysTypeMapper;
import com.dy.system.mapper.SystemDictionarydDetailMapper;
import com.dy.system.service.SystemTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SystemTyServiceImpl extends BaseServiceImpl<SystemDictionaryType> implements SystemTypeService {

    @Autowired
    private SysTypeMapper sysTypeMapper;

    @Autowired
    private SystemDictionarydDetailMapper sysDetail;

    @Override
    @Transactional(rollbackFor=Exception.class)//指定回滚,遇到异常Exception时回滚
    public void delete(Long id) {
        sysTypeMapper.delete(id);
        sysDetail.deleteType(id);
    }

    /**
     * 批量删除
     * @param ids
     */
    @Override
    @Transactional(rollbackFor=Exception.class)//指定回滚,遇到异常Exception时回滚
    public void deleteAll(List<Long> ids) {
        sysTypeMapper.deleteAll(ids);
        sysDetail.deleteAll(ids);
    }

    /**
     * 通过明细查询相关的信息
     * @param id
     * @return
     */
    @Override
    public List<SystemDictionaryDetail> findBySysType(Long id) {
        List<SystemDictionaryDetail> empById = sysTypeMapper.findEmpById(id);
        return empById;
    }

}
